<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>事件修饰符</title>
    <script src="./js/vue.js"></script>
    <style>
        #cc{
            width: 200px;
            height: 200px;
            background-color: red;
        }
        #cc1{
            width: 100px;
            height: 100px;
            background-color: blue;
        }
        #cc2{
            width: 100px;
            height: 100px;
            background-color: yellow;
        }
        #cc3{
            width: 50px;
            height: 50px;
            background-color: green;
        }
    </style>
</head>
<body>
    <div id="app">
        <div id="cc" @click.self="cclick()">
            <!-- 阻止事件冒泡 -->
            <div id="cc1" @click.stop="cc1click()"></div>
            <!-- 只触发标签自身的事件 -->
            <div id="cc2" @click.self.once="cc2click">
                <div id="cc3"></div>
            </div>
        </div>
        <!-- 阻止默认事件 -->
        <a href="http://www.baidu.com" @click.prevent="aclick" >跳转到自定义页面</a>
        <!-- 一次事件 -->
        <button @click.once="cclick">一次事件</button>
        <!-- 键盘事件修饰符 回车 -->
         <input type="text" 
         @keyup.enter.tab="keyupEnter" 
         placeholder="回车被点击了"></input>
         <!-- 键盘事件修饰符 tab -->
         <input type="text" 
         @keyup.tab="keyupTab"
         placeholder="tab被点击了"></input>

    </div>
</body>
</html>
<script>
    var app = new Vue({
        el: '#app',
        data: {
            msg: 'hello world'
        },
        methods: {
            keyupTab(){
                alert('tab被点击了')
            },  
            keyupEnter(){
                alert('回车被点击了')
            },
            cc2click(){
                alert('cc2被点击了')
            },
            aclick(){
                alert('a标签被点击了')
            },
            cc1click(){
                alert('cc1被点击了')
            },
           cclick(){
            alert('cc被点击了')
           } 
        }
    })
</script>